﻿using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using Abp.Auditing;
using AbpZeroTemplate.Chat;
using AbpZeroTemplate.Chat.Dto;
using AbpZeroTemplate.Web.Controllers;
using AbpZeroTemplate.Web.Swagger;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace AbpZeroTemplate.Api.Admin.Controllers
{
    /// <summary>SignalR
    /// </summary>
    [Area("Admin")]
    [Route("Admin/Chat/[action]")]
    [ApiName("Admin")]
    [RemoteService]
    [AbpMvcAuthorize]
    public class ChatController : AbpZeroTemplateControllerBase
    {
        private readonly IChatAppService _chatAppService;
        /// <summary>
        /// </summary>
        public ChatController(IChatAppService chatAppService)
        {
            _chatAppService = chatAppService;
        }

        [HttpGet]
        [DisableAuditing]
        public GetUserChatFriendsWithSettingsOutput GetUserChatFriendsWithSettings()
        {
            return _chatAppService.GetUserChatFriendsWithSettings();
        }


        /// <summary>获取用户消息
        /// </summary>
        [HttpGet]
        [DisableAuditing]
        public async Task<ListResultDto<ChatMessageDto>> GetUserChatMessages(GetUserChatMessagesInput input)
        {
            return await _chatAppService.GetUserChatMessages(input);
        }

        /// <summary>全部设置为已读
        /// </summary>
        [HttpPost]
        public async Task MarkAllUnreadMessagesOfUserAsRead([FromBody]MarkAllUnreadMessagesOfUserAsReadInput input)
        {
            await _chatAppService.MarkAllUnreadMessagesOfUserAsRead(input);
        }

    }
}
